using System;
using System.Data;
using SecuBat.Modularization.Plugins;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;

namespace SecuBat.Modularization
{
	/// <summary>
	/// Summary description for DatabaseManager.
	/// </summary>
	public class ModularizationDbManager
	{
		public static PluginCollection LoadActivePlugins()
		{
			PluginCollection col = new PluginCollection();
			Database db = DatabaseFactory.CreateDatabase();
			DbCommand command = db.GetStoredProcCommand("lstEPlugin");
			db.AddInParameter(command, "@i_IsActive", DbType.Int32, 1);
			using (IDataReader reader = db.ExecuteReader(command))
			{
				while (reader.Read())
				{
					Plugin p = new Plugin(reader);
					if (p != null)
						col.Add(p);
				}
			}
			return col;
		}
	}
}
